import type { PageParam, PageResult } from '@vben/request';

import { requestClient } from '#/api/request';

export namespace CmtContentLikeApi {
  export interface Like {
    id?: number;
    communityId?: number;
    merchantId?: number;
    targetType?: string;
    targetId?: number;
    userId?: number;
    createTime?: string;
  }

  export interface LikePageReqVO extends PageParam {
    targetType?: string;
    targetId?: number;
    userId?: number;
    createTime?: string[];
  }
}

export function getLikePage(params: CmtContentLikeApi.LikePageReqVO) {
  return requestClient.get<PageResult<CmtContentLikeApi.Like>>(
    '/cmt/content-like/page',
    { params },
  );
}

export function getLike(id: number) {
  return requestClient.get<CmtContentLikeApi.Like>(
    `/cmt/content-like/get?id=${id}`,
  );
}

export function createLike(data: CmtContentLikeApi.Like) {
  return requestClient.post('/cmt/content-like/create', data);
}

export function updateLike(data: CmtContentLikeApi.Like) {
  return requestClient.put('/cmt/content-like/update', data);
}

export function deleteLike(id: number) {
  return requestClient.delete(`/cmt/content-like/delete?id=${id}`);
}

export function deleteLikeList(ids: number[]) {
  return requestClient.delete(
    `/cmt/content-like/delete-list?ids=${ids.join(',')}`,
  );
}

export function exportLike(params: CmtContentLikeApi.LikePageReqVO) {
  return requestClient.download('/cmt/content-like/export-excel', { params });
}
